unit RclFolderBrownser;

interface

uses
  Classes,
  FileCtrl,
  Dialogs;

type
  TFolderBrownser = class(TCommonDialog)
  private
    FClassicDialog: Boolean;
    FDirectory: string;
    FHelpContext: Longint;
    FInitialDir: string;
    FOptions: TSelectDirOpts;
    FTitle: string;
  public
    constructor Create(AOwner: TComponent); override;
    function Execute: Boolean; override;
  published
    property ClassicDialog: Boolean read FClassicDialog write FClassicDialog
        default True;
    property Directory: string read FDirectory;
    property HelpContext: Longint read FHelpContext write FHelpContext default 0;
    property InitialDir: string read FInitialDir write FInitialDir;
    property Options: TSelectDirOpts read FOptions write FOptions default
        [sdAllowCreate, sdPerformCreate, sdPrompt];
    property Title: string read FTitle write FTitle;
  end;

implementation

constructor TFolderBrownser.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FDirectory := '';
  FInitialDir := '';
  FHelpContext := 0;
  FClassicDialog := True;
  FOptions := [sdAllowCreate, sdPerformCreate, sdPrompt];
  FTitle := '';
end;

function TFolderBrownser.Execute: Boolean;
begin
  FDirectory := InitialDir;
  if ClassicDialog then
    Result := SelectDirectory(FDirectory, Options, HelpContext)
  else
    Result := SelectDirectory(Title, InitialDir, FDirectory);
end;

end.

